/*
 * @Description: v_chenjiawei@baidu.com
 * @Version: 
 * @Autor: cjw
 * @Date: 2020-06-15 12:18:25
 * @LastEditors: cjw
 * @LastEditTime: 2020-06-15 12:32:32
 */ 
export default {
    /**
     * 替换图片大小
     * @param {*} url 图片地址 
     * @param {*} size  图片大小
     */
    replace_https(url,size) {
        console.log(size)
        try {
            if (url.indexOf('png') > -1 || url.indexOf('jpg') > -1) {
                url += navigator.userAgent.match(/Android/i) ? `?imageView2/0/w/${size}/h/${size}/format/webp` : `?imageView2/0/w/${size}/h/${size}/format/jpg/q/70`
            }
            if (url.indexOf('gif') > -1) {
                url += `?imageView2/0/w/${size}/h/${size}/format/gif`
            }
        }  
        catch (error) {
            console.log(error)
        }
        try {
            if (url.indexOf('https://') > -1) {
                return url
            } else {
                return url.replace('http://', 'https://')
            }
        }
        catch (error) {
            console.log('图片格式不正确')
            console.log(error)
        }
    }
}